package unit4.part13;

public class WeekDay {

    public static void main(String[] args) {
        Days days = Days.getDays(0);
        if (days != null) {
            System.out.println(days.name);
            System.out.println(days.needWork ? "上班" : "休息");
        }
        days = Days.getDays(1);
        if (days != null) {
            System.out.println(days.name);
            System.out.println(days.needWork ? "上班" : "休息");
        }
        days = Days.getDays(2);
        if (days != null) {
            System.out.println(days.name);
            System.out.println(days.needWork ? "上班" : "休息");
        }
        days = Days.getDays(7);
        if (days != null) {
            System.out.println(days.name);
            System.out.println(days.needWork ? "上班" : "休息");
        }
        days = Days.getDays(8);
        if (days != null) {
            System.out.println(days.name);
            System.out.println(days.needWork ? "上班" : "休息");
        }
    }
}

enum Days {
    Mon("周一", true), Tues("周二", true), Wednes("周三", true),
    Thurs("周四", true), Fri("周五", true), Sar("周六", false),
    Sun("周天", false);

    String name;
    boolean needWork;

    Days(String name, boolean needWork) {
        this.name = name;
        this.needWork = needWork;
    }

    static Days getDays(int index) {
        Days[] array = values();
        index = index - 1;
        if (index < 0 || index >= array.length) {
            return null;
        }
        return array[index];
    }
}
